import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author abin
 * @date 2024/12/14 15:10
 * @description
 */

public class Main {

    public static void main(String[] args) {
//        // 创建 ThreadTermination 实例
//        ThreadTermination termination = new ThreadTermination();
//
//        // 启动采集功能
//        termination.start();
//        System.out.println("采集线程已启动");
//
//        // 模拟运行一段时间后停止采集功能
//        try {
//            Thread.sleep(10000); // 模拟运行10秒
//        } catch (InterruptedException e) {
//            System.out.println("主线程在等待期间被中断");
//            e.printStackTrace();
//        }
//
//        // 终止采集功能
//        termination.stop();
//        System.out.println("采集线程已终止");
//
//        try {
//            termination.rptThread.join();
//        } catch (InterruptedException e) {
//            System.out.println("主线程被中断");
//            e.printStackTrace();
//        }
       // map();
        System.out.println(Constants.BASE_URL);
        System.out.println(Constants.FF);
        Constants.saf();
        System.out.println("null != null:" +(null != null));
        System.out.println("null == null:" +(null == null));
        test();
        main1(1,"2");
    }

    public static void map() {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("Apple", 1);
        map.put("Banana", 2);

        Iterator<Map.Entry<String, Integer>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, Integer> entry = iterator.next();
            System.out.println(entry.getKey() + ": " + entry.getValue());
            map.put("Cherry", 3);  // 在遍历时添加元素
        }
    }

    public static void main1(Object...args) {
        System.out.println(args[0]+" " + args[1]);
    }

    public static void test() {
        String str = "Hello, World!";
        String str1 = "Hello, World!";
        System.out.println("str==str1: " +(str==str1)); // true

        String a = "Hello, ";
        String b = "World!";
        String c = a + b;
        System.out.println("a+b==c: " +(c==a+b)); // false
        System.out.println("str==c: " +(c.intern()==str)); // false

        StringBuilder sb = new StringBuilder("Hello, World");
        String strc = sb.toString();
        System.out.println("sb.toString()==c: " +(c==strc)); //false
        System.out.println("sb.toString()==strc: " +(str==strc)); //false

        final String str2 = "Hello, ";
        final String str3 = "World!";
        String str4 = str2 + b;
        System.out.println("str2+str3==str4: " +(str4==str2+str3));

        String h = c.intern();
        System.out.println("sb1.toString()==str4: " +(str==h));
    }

    public int[] maxTargetNodes(int[][] edges1, int[][] edges2, int k) {
        // 构建edges1邻接表
        List<List<Integer>> l1 = new ArrayList<>();
        for (int i = 0; i < edges1.length; i++) {
            l1.add(new ArrayList<>());
        }
        for (int[] edge : edges1) {
            l1.get(edge[0]).add(edge[1]);
        }

        int[] dp1 = new int[edges1.length];
        for (int i = 0; i < l1.size(); i++) {
            dp1[i] = dfs(l1, i, k, 0);
        }


        // 构建edges2邻接表
        List<List<Integer>> l2 = new ArrayList<>();
        for (int i = 0; i < edges2.length; i++) {
            l2.add(new ArrayList<>());
        }
        for (int[] edge : edges2) {
            l2.get(edge[0]).add(edge[1]);
        }
        int[] dp2 = new int[edges2.length];
        for (int i = 0; i < l2.size(); i++) {
            dp2[i] = dfs(l2, i, k-1, 0);
        }

        int ans2 = 0;
        for (int i = 0; i < dp2.length; i++){
            ans2  = Math.max(ans2, dp2[i]);
        }

        int[] ans = new int[dp1.length+1];
        for (int i = 0; i < ans.length-1; i++) {
            ans[i] = dp1[i]+ans2;
        }
        ans[ans.length-1] = ans2;

        return ans;
    }

    private int dfs(List<List<Integer>> l, int i, int k, int res) {
        if (k == 0) {
            return res;
        }
        k--;
        for (int j : l.get(i)) {
            res++;
            dfs(l, j-1, k, res);
        }
        return res;
    }
}
